aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/[username]/settings/+page.server.js
blob: 7053a939c6efe5feafb57c86582f05c323a51b9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { invalid } from '@sveltejs/kit';
import { auth, get, post } from '$lib/utils';

export const actions = {
	default: async ({ cookies, request }) => {
		let user = {
			...(await get('/me', auth(cookies))),
			...Object.fromEntries(await request.formData())
		};

		try {
			await post(`/user`, user, auth(cookies));
		} catch (e) {
			return invalid(400, { message: e.message });
		}

		return { success: true };
	}
};